home *** CD-ROM | disk | FTP | other *** search
/ Language/OS - Multiplatform Resource Library / LANGUAGE OS.iso / scheme / siod / siod_v28.lha / siod.h < prev    next >
Encoding:
C/C++ Source or Header  |  1993-08-16  |  5.2 KB  |  214 lines

  1. /* Scheme In One Defun, but in C this time.
  2.  
  3.  *                   COPYRIGHT (c) 1988-1992 BY                             *
  4.  *        PARADIGM ASSOCIATES INCORPORATED, CAMBRIDGE, MASSACHUSETTS.       *
  5.  *        See the source file SLIB.C for more information.                  *
  6.  
  7. */
  8.  
  9. struct obj
  10. {short gc_mark;
  11.  short type;
  12.  union {struct {struct obj * car;
  13.         struct obj * cdr;} cons;
  14.     struct {double data;} flonum;
  15.     struct {char *pname;
  16.         struct obj * vcell;} symbol;
  17.     struct {char *name;
  18.         struct obj * (*f)(
  19. #if  !defined(VMS) && !defined(CRAY)
  20.                   ...
  21. #endif
  22.                   );} subr;
  23.     struct {struct obj *env;
  24.         struct obj *code;} closure;
  25.     struct {long dim;
  26.         long *data;} long_array;
  27.     struct {long dim;
  28.         double *data;} double_array;
  29.     struct {long dim;
  30.         char *data;} string;
  31.     struct {long dim;
  32.         struct obj **data;} lisp_array;
  33.     struct {FILE *f;
  34.         char *name;} c_file;}
  35.  storage_as;};
  36.  
  37. #define CAR(x) ((*x).storage_as.cons.car)
  38. #define CDR(x) ((*x).storage_as.cons.cdr)
  39. #define PNAME(x) ((*x).storage_as.symbol.pname)
  40. #define VCELL(x) ((*x).storage_as.symbol.vcell)
  41. #define SUBRF(x) (*((*x).storage_as.subr.f))
  42. #define FLONM(x) ((*x).storage_as.flonum.data)
  43.  
  44. #define NIL ((struct obj *) 0)
  45. #define EQ(x,y) ((x) == (y))
  46. #define NEQ(x,y) ((x) != (y))
  47. #define NULLP(x) EQ(x,NIL)
  48. #define NNULLP(x) NEQ(x,NIL)
  49.  
  50. #define TYPE(x) (((x) == NIL) ? 0 : ((*(x)).type))
  51.  
  52. #define TYPEP(x,y) (TYPE(x) == (y))
  53. #define NTYPEP(x,y) (TYPE(x) != (y))
  54.  
  55. #define tc_nil    0
  56. #define tc_cons   1
  57. #define tc_flonum 2
  58. #define tc_symbol 3
  59. #define tc_subr_0 4
  60. #define tc_subr_1 5
  61. #define tc_subr_2 6
  62. #define tc_subr_3 7
  63. #define tc_lsubr  8
  64. #define tc_fsubr  9
  65. #define tc_msubr  10
  66. #define tc_closure 11
  67. #define tc_free_cell 12
  68. #define tc_string       13
  69. #define tc_double_array 14
  70. #define tc_long_array   15
  71. #define tc_lisp_array   16
  72. #define tc_c_file       17
  73. #define tc_user_1 50
  74. #define tc_user_2 51
  75. #define tc_user_3 52
  76. #define tc_user_4 53
  77. #define tc_user_5 54
  78.  
  79. #define FO_fetch 127
  80. #define FO_store 126
  81. #define FO_list  125
  82. #define FO_listd 124
  83.  
  84. #define tc_table_dim 100
  85.  
  86. typedef struct obj* LISP;
  87.  
  88. #define CONSP(x)   TYPEP(x,tc_cons)
  89. #define FLONUMP(x) TYPEP(x,tc_flonum)
  90. #define SYMBOLP(x) TYPEP(x,tc_symbol)
  91.  
  92. #define NCONSP(x)   NTYPEP(x,tc_cons)
  93. #define NFLONUMP(x) NTYPEP(x,tc_flonum)
  94. #define NSYMBOLP(x) NTYPEP(x,tc_symbol)
  95.  
  96. #define TKBUFFERN 256
  97.  
  98. struct gen_readio
  99. {int (*getc_fcn)(char *);
  100.  void (*ungetc_fcn)(int, char *);
  101.  char *cb_argument;};
  102.  
  103. #define GETC_FCN(x) (*((*x).getc_fcn))((*x).cb_argument)
  104. #define UNGETC_FCN(c,x) (*((*x).ungetc_fcn))(c,(*x).cb_argument)
  105.  
  106. void process_cla(int argc,char **argv,int warnflag);
  107. void print_welcome(void);
  108. void print_hs_1(void);
  109. void print_hs_2(void);
  110. long no_interrupt(long n);
  111. LISP get_eof_val(void);
  112. void repl_driver(long want_sigint,long want_init);
  113. void set_repl_hooks(void (*puts_f)(),
  114.             LISP (*read_f)(),
  115.             LISP (*eval_f)(),
  116.             void (*print_f)());
  117. void repl(void) ;
  118. void err(char *message, LISP x);
  119. char *get_c_string(LISP x);
  120. long get_c_long(LISP x);
  121. LISP lerr(LISP message, LISP x);
  122.  
  123. LISP newcell(long type);
  124. LISP cons(LISP x,LISP y);
  125. LISP consp(LISP x);
  126. LISP car(LISP x);
  127. LISP cdr(LISP x);
  128. LISP setcar(LISP cell, LISP value);
  129. LISP setcdr(LISP cell, LISP value);
  130. LISP flocons(double x);
  131. LISP numberp(LISP x);
  132. LISP plus(LISP x,LISP y);
  133. LISP ltimes(LISP x,LISP y);
  134. LISP difference(LISP x,LISP y);
  135. LISP quotient(LISP x,LISP y);
  136. LISP greaterp(LISP x,LISP y);
  137. LISP lessp(LISP x,LISP y);
  138. LISP eq(LISP x,LISP y);
  139. LISP eql(LISP x,LISP y);
  140. LISP symcons(char *pname,LISP vcell);
  141. LISP symbolp(LISP x);
  142. LISP symbol_boundp(LISP x,LISP env);
  143. LISP symbol_value(LISP x,LISP env);
  144. LISP cintern(char *name);
  145. LISP rintern(char *name);
  146. LISP subrcons(long type, char *name, LISP (*f)());
  147. LISP closure(LISP env,LISP code);
  148. void gc_protect(LISP *location);
  149. void gc_protect_n(LISP *location,long n);
  150. void gc_protect_sym(LISP *location,char *st);
  151.  
  152. void init_storage(void);
  153.  
  154. void init_subr(char *name, long type, LISP (*fcn)());
  155. LISP assq(LISP x,LISP alist);
  156. LISP delq(LISP elem,LISP l);
  157. void set_gc_hooks(long type,
  158.           LISP (*rel)(),
  159.           LISP (*mark)(),
  160.           void (*scan)(),
  161.           void (*free)(),
  162.           long *kind);
  163. LISP gc_relocate(LISP x);
  164. LISP user_gc(LISP args);
  165. LISP gc_status(LISP args);
  166. void set_eval_hooks(long type,LISP (*fcn)());
  167. LISP leval(LISP x,LISP env);
  168. LISP symbolconc(LISP args);
  169. void set_print_hooks(long type,void (*fcn)());
  170. LISP lprin1f(LISP exp,FILE *f);
  171. LISP lprint(LISP exp);
  172. LISP lread(void);
  173. LISP lreadtk(long j);
  174. LISP lreadf(FILE *f);
  175. void set_read_hooks(char *all_set,char *end_set,
  176.             LISP (*fcn1)(),LISP (*fcn2)());
  177. LISP oblistfn(void);
  178. LISP vload(char *fname,long cflag);
  179. LISP load(LISP fname,LISP cflag);
  180. LISP save_forms(LISP fname,LISP forms,LISP how);
  181. LISP quit(void);
  182. LISP nullp(LISP x);
  183. void init_subrs();
  184. LISP strcons(long length,char *data);
  185. LISP read_from_string(LISP x);
  186. LISP aref1(LISP a,LISP i);
  187. LISP aset1(LISP a,LISP i,LISP v);
  188. LISP cons_array(LISP dim,LISP kind);
  189. LISP string_append(LISP args);
  190.  
  191. void init_subrs(void);
  192.  
  193. LISP copy_list(LISP);
  194.  
  195.  
  196. long c_sxhash(LISP,long);
  197. LISP sxhash(LISP,LISP);
  198.  
  199. LISP href(LISP,LISP);
  200. LISP hset(LISP,LISP,LISP);
  201.  
  202. LISP fast_print(LISP,LISP);
  203. LISP fast_read(LISP);
  204.  
  205. LISP equal(LISP,LISP);
  206.  
  207. LISP assoc(LISP x,LISP alist);
  208.  
  209. LISP make_list(LISP x,LISP v);
  210.  
  211. void set_fatal_exit_hook(void (*fcn)(void));
  212.  
  213. LISP parse_number(LISP x);
  214.